import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class Test {
    public static void main(String[] args) {
        int[] arr = {1,1,2};
    }
    //买卖股票含手续费
    public int maxProfit(int[] prices, int fee) {
        int n = prices.length;

        int[] f = new int[n];//第i天持有股票的最大利润
        int[] g = new int[n];//第i天不持有股票的最大利润
        f[0] = -prices[0];
        for(int i=1;i<n;i++) {
            f[i] = Math.max(f[i-1],g[i-1]-prices[i]);
            g[i] = Math.max(g[i-1],f[i-1]+prices[i]-fee);
        }
        return g[n-1];
    }
   /* *
     * 求所有子集的异或和*/
    int sum = 0;
    int path = 0;//记录异或和
    public int subsetXORSum(int[] nums) {
        dfs(nums,0);
        return sum;
    }
    public void dfs(int[] nums,int pos) {
        sum+=path;
        for(int i=pos;i<nums.length;i++) {
            path^=nums[i];
            dfs(nums,i+1);
            path^= nums[i];//回溯
        }

    }
}
